package com.nanxun.controller;


import com.nanxun.domain.Member;
import com.nanxun.model.Result;
import com.nanxun.service.SendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 *
 * 短信业务控制层
 * @param
 * @return
 * @author nanxun
 * @create 2025/6/22
 **/

@Api(tags = "短信业务接口管理")
@RequestMapping("p/sms")
@RestController
public class SendController {

    @Resource
    private SendService sendService;


    /**
     *
     * 获取短信验证码
     * @param map 手机号码
     * @return com.nanxun.model.Result<java.lang.String>
     * @author nanxun
     * @create 2025/6/22
     **/

    @ApiOperation("获取短信验证码")
    @PostMapping("send")
    public Result<String> sendPhoneMsg(@RequestBody Map<String,Object> map){
        sendService.sendPhoneMsg(map);
        return Result.success("短信发送成功");
    }


    /**
     *
     * 绑定手机号码
     * @param map 手机号码phonenum，短信验证码code
     * @return com.nanxun.model.Result<java.lang.String>
     * @author nanxun
     * @create 2025/6/22
     **/

    // p/sms/savePhone
    @ApiOperation("绑定手机号码")
    @PostMapping("savePhone")
    public Result<String> saveMsgPhone(@RequestBody Map<String,Object> map){
        Boolean saved = sendService.saveMsgPhone(map);
        return Result.handle(saved);
    }


}
